#include "bullet.h"
#include "config.h"
Bullet::Bullet()
{
    //加载子弹
    m_Bullet.load(BULLET_PATH);
    //坐标初始化
    m_X=GAME_WIDTH*0.5-m_Bullet.width()*0.5;
    m_Y=GAME_HEIGHT;

    //子弹是否空闲
    m_Free=true;


    //速度
    m_Speed=BULLET_SPEED;


    //矩形框，碰撞检测
    m_Rect.setWidth(m_Bullet.width());
    m_Rect.setHeight(m_Bullet.height());
    m_Rect.moveTo(m_X,m_Y);


}

void Bullet::updatePosition()
{
    //空闲子弹
    if(m_Free)
        return;

    //移动
    m_Y-=m_Speed;
    m_Rect.moveTo(m_X,m_Y);

    if(m_Y<=-m_Rect.height())
        m_Free=true;



}
